/**  \file HouseProfile.qml
\brief Splash screen definition

Price My House for Nokia mobile platforms.

\author © 2011 Enrico Miglino / Tech Consulting (enrico.miglino@ovi.com)
\author "Evimin Fiyati Price My House" is protected by the copyright law
\author Distributed under the LGPL 3.0 license.
\date 2011

\par Licensing notes

    "Price My House" is free software: you can redistribute it
    and/or modify it under the terms of the Lesser GNU General Public License
    as published by the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    "Price My House" is distributed in the hope that it
    will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    Lesser GNU General Public License for more details.

    You should have received a copy of the Lesser GNU General Public License
    along with "Price My House".
    If not, see <http://www.gnu.org/licenses/>.

*/

import QtQuick 1.0
import "../elements" as Elements
import "HouseProfile.js" as JLocals
import "../elements/PriceMyHouse.js" as Jmain
import "../Qt-Complex/Geometry.js" as Geometry

/*
  The DataItem type is a special item that includes all the properties, classes and
  methods used to profile the house.
  */
HouseItem {
    id: house

    width: parent.width; height: parent.height

    property int pageNum: 1; property int pageLeft: 1; property int pageRight: 2
    property int maxPages: 7; property int pagesMargin: 10; property bool summaryView: false
    // Interface methods for internal usage
    function show_hideSummary() { JLocals.changeSummaryStatus(); }
    function slide_pageNum(page, set_state) { JLocals.setPageStatus(page, set_state) }
    function move_leftPage() { JLocals.pageToLeft(); }
    function move_rightPage() { JLocals.pageToRight(); }

    // The main background recatngle under all the sliding pages
    Rectangle {
        id: mainBackground
        width: parent.width; height: parent.height; color: "#d1d1d1";
    }
    // Page 1
    Item {
        id: form1
        width: parent.width - Math.round(parent.width * 0.08);
        height: parent.height - currentPage.height;
        anchors.leftMargin: Math.round(parent.width * 0.04)
        state: "Center"

        Flickable {
            id: form1flicked
            width: parent.width; height: parent.height; clip: true
            anchors.fill: parent; contentWidth: parent.width; contentHeight: module1.height;

            Page1 {
                id: module1

                txt1Label: house.p1_txt1; txt2Label: house.p1_txt2; txt3Label: house.p1_txt3
                txt4Label: house.p1_txt4;  txt5Label: house.p1_txt5
                fld1: house.p1_fld1; fld2: house.p1_fld2; fld3: house.p1_fld3;
                fld4: house.p1_fld4; fld5: house.p1_fld5
                anchors.top: parent.top; anchors.topMargin: Geometry.getFormBorder() * 5
                width: parent.width;
                height: (Geometry.getFieldHeight() * 12) + (Geometry.getFieldSpacing() * 6)

                onTxt1Click: { }
                onTxt2Click: { }
                onTxt3Click: { }
                onTxt4Click: { }
                onTxt5Click: { }

            }
        }
        states: [
            State { name: "Right";
                AnchorChanges { target: form1;
                    anchors.left: parent.right; anchors.right: undefined;
                }
            },
            State { name: "Left";
                AnchorChanges { target: form1;
                    anchors.right: parent.left; anchors.left: undefined
                }
            },
            State { name: "Center";
                AnchorChanges { target: form1;
                    anchors.left: parent.left; anchors.right: undefined
                }
            }
        ]
        transitions: Transition {
            AnchorAnimation { duration: Jmain.animDuration; easing.amplitude: 1; easing.type: Easing.InOutQuad }
        }
    }

    Item {
        id: form2
        width: parent.width - Math.round(parent.width * 0.08);
        height: parent.height - currentPage.height;
        anchors.leftMargin: Math.round(parent.width * 0.04)
        state: "Left"

        Flickable {
            id: form2flicked
            width: parent.width; height: parent.height; clip: true
            anchors.fill: parent; contentWidth: parent.width; contentHeight: module2.height;

            Page2 {
                id: module2

                txt1Title: house.p2_txt1; txt2Title: house.p2_txt2
                opt1: house.p2_opt1; opt2: house.p2_opt2; opt3: house.p2_opt3;
                opt4: house.p2_opt4; opt5: house.p2_opt5
                inf1: house.p2_inf1; inf2: house.p2_inf2; inf3: house.p2_inf3;
                inf4: house.p2_inf4; inf5: house.p2_inf5;
                anchors.top: parent.top; anchors.topMargin: Geometry.getSeparator() * 2
                width: parent.width;
                height: (Geometry.getFieldHeight() * 12) + (Geometry.getFieldSpacing() * 6)
            }
        }
        states: [
            State { name: "Right";
                AnchorChanges { target: form2;
                    anchors.left: parent.right; anchors.right: undefined;
                }
            },
            State { name: "Left";
                AnchorChanges { target: form2;
                    anchors.right: parent.left; anchors.left: undefined
                }
            },
            State { name: "Center";
                AnchorChanges { target: form2;
                    anchors.left: parent.left; anchors.right: undefined
                }
            }
        ]
        transitions: Transition {
            AnchorAnimation { duration: Jmain.animDuration; easing.amplitude: 1; easing.type: Easing.InOutQuad }
        }
    }

    Item {
        id: form3
        width: parent.width - Math.round(parent.width * 0.08);
        height: parent.height - currentPage.height;
        anchors.leftMargin: Math.round(parent.width * 0.04)
        state: "Left"

        Flickable {
            id: form3flicked
            width: parent.width; height: parent.height; clip: true
            anchors.fill: parent; contentWidth: parent.width; contentHeight: module3.height;

            Page3 {
                id: module3

                pageState: 1
                txt1Label: house.p3_txt1; txt2Label: house.p3_txt2; txt3Label: house.p3_txt3
                txt4Label: house.p3_txt4; txt1Note: house.p3_txt5
                fld1: house.p3_fld1; fld2: house.p3_fld2; fld3: house.p3_fld3; fld4: house.p3_fld4;
                anchors.top: parent.top; anchors.topMargin: Geometry.getFormBorder() * 5
                width: parent.width;
                height: (Geometry.getFieldHeight() * 12) + (Geometry.getFieldSpacing() * 6)

                onTxt1Click: { }
                onTxt2Click: { }
                onTxt3Click: { }
                onTxt4Click: { }
            }
        }
        states: [
            State { name: "Right";
                AnchorChanges { target: form3;
                    anchors.left: parent.right; anchors.right: undefined;
                }
            },
            State { name: "Left";
                AnchorChanges { target: form3;
                    anchors.right: parent.left; anchors.left: undefined
                }
            },
            State { name: "Center";
                AnchorChanges { target: form3;
                    anchors.left: parent.left; anchors.right: undefined
                }
            }
        ]
        transitions: Transition {
            AnchorAnimation { duration: Jmain.animDuration; easing.amplitude: 1; easing.type: Easing.InOutQuad }
        }
    }

    Item {
        id: form4
        width: parent.width - Math.round(parent.width * 0.08);
        height: parent.height - currentPage.height;
        anchors.leftMargin: Math.round(parent.width * 0.04)
        state: "Left"

        Flickable {
            id: form4flicked
            width: parent.width; height: parent.height; clip: true
            anchors.fill: parent; contentWidth: parent.width; contentHeight: module4.height;

            Page4 {
                id: module4

                pageState: 1
                txt1Label: house.p4_txt1; txt2Label: house.p4_txt2; txt3Label: house.p4_txt3
                txt1Title: house.p4_txt4; txt4Label: house.p4_txt5; txt5Label: house.p4_txt6
                fld1: house.p4_fld1; fld2: house.p4_fld2; fld3: house.p4_fld3; fld4: house.p4_fld4;
                fld5: house.p4_fld5;
                anchors.top: parent.top; anchors.topMargin: Geometry.getFormBorder() * 5
                width: parent.width;
                height: (Geometry.getFieldHeight() * 12) + (Geometry.getFieldSpacing() * 6)

                onTxt1Click: { }
                onTxt2Click: { }
                onTxt3Click: { }
                onTxt4Click: { }
                onTxt5Click: { }
            }
        }
        states: [
            State { name: "Right";
                AnchorChanges { target: form4;
                    anchors.left: parent.right; anchors.right: undefined;
                }
            },
            State { name: "Left";
                AnchorChanges { target: form4;
                    anchors.right: parent.left; anchors.left: undefined
                }
            },
            State { name: "Center";
                AnchorChanges { target: form4;
                    anchors.left: parent.left; anchors.right: undefined
                }
            }
        ]
        transitions: Transition {
            AnchorAnimation { duration: Jmain.animDuration; easing.amplitude: 1; easing.type: Easing.InOutQuad }
        }
    }

    Item {
        id: form5
        width: parent.width - Math.round(parent.width * 0.08);
        height: parent.height - currentPage.height;
        anchors.leftMargin: Math.round(parent.width * 0.04)
        state: "Left"

        Flickable {
            id: form5flicked
            width: parent.width; height: parent.height; clip: true
            anchors.fill: parent; contentWidth: parent.width; contentHeight: module5.height;

            Page5 {
                id: module5
                pageState: 1
                txt1Title: house.p5_txt1; txt2Title: house.p5_txt2; txt3Title: house.p5_txt3
                opt1: house.p5_opt1; opt2: house.p5_opt2; opt3: house.p5_opt3; opt4: house.p5_opt4;
                opt5: house.p5_opt5
                inf1: house.p5_inf1; inf2: house.p5_inf2; inf3: house.p5_inf3; inf4: house.p5_inf4;
                inf5: house.p5_inf5;
                anchors.top: parent.top; anchors.topMargin: Geometry.getFormBorder() * 5
                width: parent.width;
                height: (Geometry.getFieldHeight() * 12) + (Geometry.getFieldSpacing() * 6)
            }
        }

        states: [
            State { name: "Right";
                AnchorChanges { target: form5;
                    anchors.left: parent.right; anchors.right: undefined;
                }
            },
            State { name: "Left";
                AnchorChanges { target: form5;
                    anchors.right: parent.left; anchors.left: undefined
                }
            },
            State { name: "Center";
                AnchorChanges { target: form5;
                    anchors.left: parent.left; anchors.right: undefined
                }
            }
        ]
        transitions: Transition {
            AnchorAnimation { duration: Jmain.animDuration; easing.amplitude: 1; easing.type: Easing.InOutQuad }
        }
    }

    Item {
        id: form6
        width: parent.width - Math.round(parent.width * 0.08);
        height: parent.height - currentPage.height;
        anchors.leftMargin: Math.round(parent.width * 0.04)
        state: "Left"

        Flickable {
            id: form6flicked
            width: parent.width; height: parent.height; clip: true
            anchors.fill: parent; contentWidth: parent.width; contentHeight: module6.height;

            Page6 {
                id: module6

                // Data fields and parameters association to the form elements.
                txt1Label: house.p6_txt1; txt2Label: house.p6_txt2;
                txt3Label: house.p6_txt3; txt4Label: house.p6_txt4;
                fld1: house.p6_fld1; fld2: house.p6_fld2;
                fld3: house.p6_fld3; fld4: house.p6_fld4;
                opt1: house.p6_opt1; inf1: house.p6_inf1;
                anchors.top: parent.top; anchors.topMargin: Geometry.getFormBorder() * 5
                width: parent.width;
                height: (Geometry.getFieldHeight() * 12) + (Geometry.getFieldSpacing() * 6)

                onTxt1Click: { }
                onTxt2Click: { }
                onTxt3Click: { }
                onTxt4Click: { }
            }
        }

        states: [
            State { name: "Right";
                AnchorChanges { target: form6;
                    anchors.left: parent.right; anchors.right: undefined;
                }
            },
            State { name: "Left";
                AnchorChanges { target: form6;
                    anchors.right: parent.left; anchors.left: undefined
                }
            },
            State { name: "Center";
                AnchorChanges { target: form6;
                    anchors.left: parent.left; anchors.right: undefined
                }
            }
        ]
        transitions: Transition {
            AnchorAnimation { duration: Jmain.animDuration; easing.amplitude: 1; easing.type: Easing.InOutQuad }
        }
    }

    Item {
        id: form7
        width: parent.width - Math.round(parent.width * 0.08);
        height: parent.height - currentPage.height;
        anchors.leftMargin: Math.round(parent.width * 0.04)
        state: "Left"

        Flickable {
            id: form7flicked
            width: parent.width; height: parent.height; clip: true
            anchors.fill: parent; contentWidth: parent.width; contentHeight: module7.height;

            Page7 {
                id: module7

                txt1Label: house.p7_txt1; txt2Label: house.p7_txt3; txt1Title: house.p7_txt2
                fld1: house.p7_fld1; fld2: house.p7_fld2; opt1: house.p7_opt1;
                opt2: house.p7_opt2; opt3: house.p7_opt3; inf1: house.p7_inf1;
                inf2: house.p7_inf2; inf3: house.p7_inf3;
                anchors.top: parent.top; anchors.topMargin: Geometry.getFormBorder() * 5
                width: parent.width;
                height: (Geometry.getFieldHeight() * 12) + (Geometry.getFieldSpacing() * 6)

                onTxt1Click: { }
                onTxt2Click: { }
            }
        }

        states: [
            State { name: "Right";
                AnchorChanges { target: form7;
                    anchors.left: parent.right; anchors.right: undefined;
                }
            },
            State { name: "Left";
                AnchorChanges { target: form7;
                    anchors.right: parent.left; anchors.left: undefined
                }
            },
            State { name: "Center";
                AnchorChanges { target: form7;
                    anchors.left: parent.left; anchors.right: undefined
                }
            }
        ]
        transitions: Transition {
            AnchorAnimation { duration: Jmain.animDuration; easing.amplitude: 1; easing.type: Easing.InOutQuad }
        }
    }

    // This object stay on top of the forms showing the current
    // page number and title (optional)
    NumberHeader {
        id: currentPage
        anchors.top: parent.top; width: parent.width; page: pageNum
        maxPages: maxPages; title1: house._sectionName
    }
}
